
function Results(){}
Results.prototype.init = function(){
    var current = this;
    $('.showDetails').click(function(){ 
        current.showDetailsClick.call(current, $(this));
    });
    $('.editDetails').click(function(){ 
        current.editResult.call(current, $(this));
    });
}

Results.prototype.showDetailsClick = function(link){
    this._showDetailsElements(link);
    this._swapLink(link, "-", this.hideDetailsElements);
}

Results.prototype.hideDetailsElements = function(link){
    this._hideDetailsElements(link);
    this._swapLink(link, "+", this.showDetailsClick);
}

Results.prototype.editResult = function(link){
    var keyValue = link.parent().parent().parent().parent().children("#key").val();
    var titleValue = link.parent().parent().parent().parent().children("#title").val();
    var noteValue = link.parent().children("#note").val();
    console.log("key: " + keyValue + " | " + "title: " + titleValue + " | " + "note: " + noteValue + " | ");
    
    //link.parent().parent().parent().parent().children(":input").each( function() {
    //    console.log( $(this).html());
    //});
    $.post("/todo/put", { key: keyValue, title: titleValue, note: noteValue } );
}

//$.post("test.php", { name: "John", time: "2pm" } );


// Private Methods
Results.prototype._showDetailsElements = function(link){
    this._displayDetailsElements(link, "show"); //jQuery.fn.show("slow")
}

Results.prototype._hideDetailsElements = function(link){
    this._displayDetailsElements(link, "hide");
}

Results.prototype._swapLink = function(link, text, methodAdd){
    var current = this;
    link.html(text).unbind().click(function(){ 
        methodAdd.call(current, link);
    });
}

Results.prototype._displayDetailsElements = function(link, methodType){
    //link.parent().parent().children(".resultDetails").method.call();
    if(methodType=="show")
        link.parent().parent().children(".resultDetails").show("slow");
    else
        link.parent().parent().children(".resultDetails").hide("slow");
}